package com.study.hot.jetpack.demo_words.db;

import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import java.util.List;

/**
 * <pre>
 *     author : slx
 *     time   : 2020/03/30
 *     desc   :
 * </pre>
 */
@Dao
public interface WordsDao {

    @Insert
    void insert(Words... words);

    @Delete
    void delete(Words... words);

    @Update
    void update(Words... words);

    @Query("DELETE FROM Words")
    void deleteAll();

    @Query("SELECT * FROM Words")
    LiveData<List<Words>> getAllWords();

    /**
     * 模糊查询
     *
     * @param english
     * @return
     */
    @Query("SELECT * FROM Words WHERE words_english LIKE :english")
    LiveData<List<Words>> getWordsByEnglish(String english);
}
